﻿<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
                assembly="Inovout.Organization"
				        namespace="Inovout.Organization.Domain">

  <class name="OrganizationUnit" table="Organization_OrganizationUnit">
    <id name="Id" access="field.camelcase"
        column="OrganizationUnitId" type="Int32">
      <generator class="native" />
    </id>
    <property name="Name" />
    <set name="Children" inverse="false" cascade="all">
      <key column="ParentId"></key>
      <one-to-many  class="Inovout.Organization.Domain.OrganizationUnit,Inovout.Organization"/>
    </set>
    <set name="Employees" table="Organization_OrganizationUnit_Employees"   inverse="false" cascade="all">
      <key column="OrganizationUnitId"></key>
      <many-to-many column="EmployeeId"  class="Inovout.Organization.Domain.Employee,Inovout.Organization"/>
    </set>
    <set name="Positions" table="Organization_OrganizationUnit_Positions"   inverse="false" cascade="all">
      <key column="OrganizationUnitId"></key>
      <many-to-many  column="PositionId" class="Inovout.Organization.Domain.Position,Inovout.Organization"/>
    </set>

    <many-to-one name="Manager" column="ManagerId"  class="Inovout.Organization.Domain.Employee,Inovout.Organization" cascade="save-update"  />
   
    <property name="NamePath" />

    <property name="CreatedTime" access="field.camelcase" />
    <property name="CreatedUserName" access="field.camelcase" />
    <property name="ModifiedTime" access="field.camelcase" />
    <property name="ModifiedUserName" access="field.camelcase" />
    <property name="AccessedTime" access="field.camelcase" />
    <property name="AccessedUserName" access="field.camelcase" />
    <property name="Memo" />
    <property name="IsInvalid" />
  </class>
</hibernate-mapping>



